<template>
	<view class="main">
		<van-toast id="van-toast" />
		<van-dialog id="van-dialog" />
		<view class="hand">
			提现管理
		</view>
		<view class="show">
			<van-tabs v-model="active">
				<van-tab title="收益提现">
					<view class="sone">
						<input placeholder="请输入提现金额" v-model="txmoney" type="number" maxlength="6" />
						<view class="sonehand">
							<view class="soneleft">
								当前可提现金额: <span class="slefttxt">¥{{slist.amount}}</span>
							</view>
							<view class="soneleft">
								已提现金额: <span class="slefttxt">¥{{slist.winthdrawn}}</span>
							</view>
						</view>
						<view class="sonejb" @click="jbtn">
							解绑银行卡
						</view>
						<view class="sonez" @click="tixian">
							确认提交
						</view>
						<!-- <view class="sonez" @click="checkTransResult('202207151610210045439400000100')">H5</view> -->
					</view>
					<view class="sonexia">
						<view class="sxone">
							温馨提示:
						</view>
						<view class="sxtwo">
							提现需要在“个人资料”中输入真实姓名；<br />
							提现金额请输入整数，金额不能小于1元；<br />
							一天只能提现一次；<br />
							提交成功不代表提现成功，提交后可以在“提现记录”中查看提现结果；
						</view>
					</view>

				</van-tab>
				<van-tab title="提现记录">

					<van-tabs v-model="active1" @change="gbtn">
						<van-tab title="待处理" name="a">
							<view class="cdjl-0" v-if="value">
								<view class="cdjl-0-l" @click="onShowDatePicker('range')">
									{{value[0]}}
								</view>-
								<view class="cdjl-0-l" @click="onShowDatePicker('range')">
									{{value[1]}}
								</view>
							</view>
							<view class="tapthree">
								<van-collapse v-model="activeNames1">
									<van-pull-refresh v-model="arefreshing" @refresh="aonRefresh">
										<van-list v-model="aloading" :finished="afinished" finished-text="没有更多了"
											@load="aloadMore">
											<van-cell v-for="(item, index) in alist" :key="index">
												<van-collapse-item :name="index">
													<template #title>
														<view>
															<view class="tphand">¥{{item.amount}}</view>
															<view class="tpfoot">{{item.createTime}}</view>
														</view>
														<view class="ztai">待处理</view>
													</template>
													<view class="showtap">
														<view class="stone">
															<view class="stoneleft">提现金额： </view>
															<view class="stoneright">¥{{item.winthdrawn}}</view>
														</view>
														<view class="stone">
															<view class="stoneleft">提现状态：</view>
															<view class="stoneright strthree">待处理</view>
														</view>
														<view class="stone">
															<view class="stoneleft">订单编号： </view>
															<view class="stoneright">{{item.orderNum}}</view>
														</view>
														<view class="stwo" @click="mbtn(item.orderNum)"
															v-show="item.winStatus==3&&item.ways==2">
															提现到卡
														</view>
														<view class="stwo" @click="hlbbtn(item.orderNum)"
															v-show="item.winStatus==4">
															提现到卡
														</view>
													</view>
												</van-collapse-item>


											</van-cell>
										</van-list>
									</van-pull-refresh>
								</van-collapse>
							</view>
						</van-tab>
						<van-tab title="提现成功" name="b">
							<view class="cdjl-0" v-if="value">
								<view class="cdjl-0-l" @click="onShowDatePicker('range')">
									{{value[0]}}
								</view>-
								<view class="cdjl-0-l" @click="onShowDatePicker('range')">
									{{value[1]}}
								</view>
							</view>
							<view class="tapthree">
								<van-collapse v-model="activeNames2">
									<van-pull-refresh v-model="brefreshing" @refresh="bonRefresh">
										<van-list v-model="bloading" :finished="bfinished" finished-text="没有更多了"
											@load="bloadMore">
											<van-cell v-for="(item, index) in blist" :key="index">
												<van-collapse-item :name="index">
													<template #title>
														<view>
															<view class="tphand">+¥{{item.amount}}</view>
															<view class="tpfoot">{{item.createTime}}</view>
														</view>
														<view class="ztai">提现成功</view>
													</template>
													<view class="showtap">
														<view class="stone">
															<view class="stoneleft">提现金额： </view>
															<view class="stoneright">¥{{item.winthdrawn}}</view>
														</view>
														<view class="stone">
															<view class="stoneleft">提现状态：</view>
															<view class="stoneright strthree">提现成功</view>
														</view>
														<view class="stone">
															<view class="stoneleft">订单编号： </view>
															<view class="stoneright">{{item.orderNum}}</view>
														</view>
													</view>
												</van-collapse-item>

											</van-cell>
										</van-list>
									</van-pull-refresh>
								</van-collapse>
							</view>
						</van-tab>
						<van-tab title="提现失败" name="c">
							<view class="cdjl-0" v-if="value">
								<view class="cdjl-0-l" @click="onShowDatePicker('range')">
									{{value[0]}}
								</view>-
								<view class="cdjl-0-l" @click="onShowDatePicker('range')">
									{{value[1]}}
								</view>
							</view>
							<view class="tapthree">
								<van-collapse v-model="activeNames3">
									<van-pull-refresh v-model="crefreshing" @refresh="conRefresh">
										<van-list v-model="cloading" :finished="cfinished" finished-text="没有更多了"
											@load="cloadMore">
											<van-cell v-for="(item, index) in clist" :key="index">
												<van-collapse-item :name="index">
													<template #title>
														<view>
															<view class="tphand">¥{{item.amount}}</view>
															<view class="tpfoot">{{item.createTime}}</view>
														</view>
														<view class="ztai" style="color:#F078CE ;">失败</view>
													</template>
													<view class="showtap">
														<view class="stone">
															<view class="stoneleft">提现金额： </view>
															<view class="stoneright">¥{{item.winthdrawn}}</view>
														</view>
														<view class="stone">
															<view class="stoneleft">提现状态：</view>
															<view class="stoneright strone">失败</view>
														</view>
														<view class="stone">
															<view class="stoneleft">失败原因：</view>
															<view class="stoneright strtwo">{{item.msg}}</view>
														</view>
														<view class="stone">
															<view class="stoneleft">订单编号： </view>
															<view class="stoneright">{{item.orderNum}}</view>
														</view>
													</view>
												</van-collapse-item>

											</van-cell>
										</van-list>
									</van-pull-refresh>
								</van-collapse>
							</view>
						</van-tab>
					</van-tabs>
				</van-tab>
			</van-tabs>
		</view>
		<date-picker :show="showPicker" :type="type" class="mask" :value="value" :show-tips="true" :begin-text="'开始'"
			:end-text="'结束'" :show-seconds="true" @confirm="onSelected" @cancel="onCancel"></date-picker>
		<van-popup v-model="eshow">
			<view class="tannei">
				<view style="font-size: 30upx;font-weight: 700;text-align: center;margin: 20upx 0;">
					企业注册
				</view>
				<view class="eone">
					email:<input placeholder="邮箱号" v-model="email" />
				</view>
				<view class="tfshow" @click="qybtn">
					提交
				</view>
			</view>
		</van-popup>
		


	</view>
</template>

<script>
	import tou_hand1 from '../../components/tou_hand1/tou_hand1.vue'
	import datePicker from "../../components/mx-datepicker.vue";
	import {
		formatDate
	} from '../../common/formatDate.js';
	import Dialog from '../../wxcomponents/dist/dialog/dialog';
	export default {
		components: {
			tou_hand1,
			datePicker
		},
		mounted() {

		},

		data() {
			return {
				active: "",
				active1: "",
				activeNames1: [''], //当前展开面板的 name
				activeNames2: [''], //当前展开面板的 name
				activeNames3: [''], //当前展开面板的 name
				money: 0, //用户当前可提现金额
				ztai: 0, //查询类型；0：待处理1：提现成功2：提现失败
				value: ['请选择开始时间', '请选择结束时间'],
				type: 'range', //时间选择器
				showPicker: false, //时间选择器
				aloading: false,
				afinished: false,
				arefreshing: false,
				apageNum: 1, //页码
				apageSize: 10, //每页显示的条数
				bloading: false,
				bfinished: false,
				brefreshing: false,
				bpageNum: 1, //页码
				bpageSize: 10, //每页显示的条数
				cloading: false,
				cfinished: false,
				crefreshing: false,
				cpageNum: 1, //页码
				cpageSize: 10, //每页显示的条数
				alist: [], //待处理数据
				blist: [], //提现成功数据
				clist: [], //提现失败数据
				txmoney: '', //提现金额
				slist: {},
				eshow: false,
				email: '',
				times: 0,
				timer:null,
				oneurl:'',
				twourl:'',
				backid:'',
			}
		},
		onLoad(option) {
			this.backid=option.backid
			this.show();
			if (this.active1 == 'a') {
				this.aloadMore();
			} else if (this.active1 == 'b') {
				this.bloadMore()
			} else if (this.active1 == 'c') {
				this.cloadMore()
			}
		},
		onShow() {
			// this.oneurl=location.href.split('?')[0]
			// this.twourl=location.href.split('#')[1]
			this.oneurl = '';
			this.twourl = '';
			this.usermoney();
			if(this.backid==4000){
				this.$toast.success('开户成功')
			}else if(this.backid==4001){
				this.$toast.success('绑卡成功')
			}else if(this.backid==4002){
				this.$toast.success('密码设置成功')
			}else if(this.backid==4003){
				this.$toast.success('提交成功,可到提现记录查看到账情况')
			}
			
		},
		methods: {
			//获取用户可提现金额
			usermoney() {
				this.$base.request('manager/getMoneys', 'GET')
					.then(res => {
						if (res.data.code == 200) {
							this.slist = res.data.data
						} else {
							this.$toast.fail(res.data.msg)
							return
						}
					})
					.catch(err => {

					})
			},
			//确认提现
			tixian() {
				if (!this.txmoney) {
					this.$toast.fail('请输入提现金额')
					return
				}
				var y = String(this.txmoney).indexOf(".") + 1; //获取小数点的位置
				if (y > 0) {
					this.$toast.fail('请输入整数金额')
					return
				}
				if (this.txmoney > this.slist.amount) {
					this.$toast.fail('当前可提现金额不足')
					return;
				}
				var appid=uni.getStorageSync('user').appid
				this.$base.request('payChannel/check/appid'+ '/' + appid, 'GET')
				.then(res => {
					if (res.data.code == 200) {
						if(res.data.data=="H"){
							this.helibaogo()
						}else if(res.data.data=="Z"){
							this.baofutixian()
						}else {
							// this.baofutixian()
							this.gotwo()
						}
					} else {
						this.$toast.fail(res.data.msg)
					}
				})
				.catch(err => {
							
				})
				
			},
			baofutixian(){
				this.$base.request('manager/getBaofooCardInfo', 'GET')
				.then(res => {
					if (res.data.code == 200) {
						Dialog.confirm({
							title: '提示',
							message:'您确认提现至<br/>'+'开户银行:【'+res.data.data.bankName+'】<br/>'+'持卡人:【'+res.data.data.cardUserName+'】<br/>'+'卡号：'+res.data.data.cardNo
						}).then(() => {
							this.gotwo()
						}).catch(() => {
						
						});
					} else {
						this.gotwo()
					}
				})
				.catch(err => {
							
				})
			},
			helibaogo(){
				this.$base.request('manager/gethlbCardInfo', 'POST')
				.then(res => {
					if (res.data.code == 200) {
						Dialog.confirm({
							title: '提示',
							message:'您确认提现至<br/>'+'开户银行:【'+res.data.data.bankName+'】<br/>'+'持卡人:【'+res.data.data.accountName+'】<br/>'+'卡号：'+res.data.data.accountNo
						}).then(() => {
							this.helibaotixian()
						}).catch(() => {
						
						});
					} else {
						this.helibaotixian()
					}
				})
				.catch(err => {
							
				})
			},
			helibaotixian(){
				let data = {
					money: this.txmoney,
					token: uni.getStorageSync('userToken')
				}
				uni.showLoading({
					title: '请稍候',
					mask: true
				})
				this.$base.request('manager/withd', 'POST', data)
					.then(res => {
						uni.hideLoading()
						this.usermoney()
						if (res.data.code == 200) {
							this.$toast.success(res.data.msg)
						} else if (res.data.code == 5000) {
							Dialog.confirm({
								title: '提示',
								message:'您尚未开户，请先开户'
							}).then(() => {
								uni.navigateTo({
									url: '../enter_idcard/enter_idcard'
								});
							})
							
							// this.checkTransResult(res.data.data)
						}else if(res.data.code == 5001){
							var arr=res.data.data
							if(arr.credentialUploadStatus==0){
								Dialog.confirm({
									title: '提示',
									message:'您尚未上传资质，请先上传资质'
								}).then(() => {
									uni.navigateTo({
										url: '../upload_qualification/upload_qualification?orderNo=' + arr.orderNo
									});
								})
							}else if(arr.credentialUploadStatus){
								Dialog.alert({
								  title: '提示',
								  message: res.data.msg,
								}).then(() => {
									
								})
								
							}
							
						} else if(res.data.code == 5003){
							var arr=res.data.data
							Dialog.confirm({
								title: '提示',
								message:'您尚未上传资质，请先上传资质'
							}).then(() => {
								uni.navigateTo({
									url: '../upload_qualification/upload_qualification?merchantNo=' + arr.merchantNo + '&orderNo=' + arr.orderNo
								});
							})
						} else {
							this.$toast.fail(res.data.msg)
							return
						}
						
				
					})
					.catch(err => {
				
				})
			},
			gotwo(){
				let data = {
					money: this.txmoney,
					token: uni.getStorageSync('userToken')
				}
				uni.showLoading({
					title: '请稍候',
					mask: true
				})
				this.$base.request('manager/withd', 'POST', data)
					.then(res => {
						uni.hideLoading()
						this.usermoney()
						if (res.data.code == 200) {
							this.$toast.success(res.data.msg)
						} else if (res.data.code == 4000) {
							this.h5btn()
						} else if (res.data.code == 4001) {
							Dialog.confirm({
								title: '提示',
								message: res.data.msg
							}).then(() => {
								var bb=this.twourl.split('?')[0]+'?backid=4001'
								var nowurl=this.oneurl+'#'+bb
								window.location.href = res.data.data+'?Address='+nowurl
							}).catch(() => {
				
							});
						}else if (res.data.code == 4002) {
							Dialog.confirm({
								title: '提示',
								message: res.data.msg
							}).then(() => {
								var bb=this.twourl.split('?')[0]+'?backid=4002'
								var nowurl=this.oneurl+'#'+bb
								window.location.href = res.data.data+'?Address='+nowurl
							}).catch(() => {
							
							});
						} else if (res.data.code == 4003) {
							Dialog.confirm({
								title: '提示',
								message: res.data.msg
							}).then(() => {
								var bb=this.twourl.split('?')[0]+'?backid=4003'
								var nowurl=this.oneurl+'#'+bb
								window.location.href = res.data.data+'?Address='+nowurl
							}).catch(() => {
							
							});
						}else if (res.data.code == 4005) {
							this.checkTransResult(res.data.data)
						} else {
							var toast = Toast({
								duration: 4000,
								message: ''
							})
							toast.message = res.data.msg
							// this.$toast.fail(res.data.msg)
						}
				
					})
					.catch(err => {
				
				})
			},
			show() {
				var nowtime = formatDate(new Date(), 'yyyy-MM-dd');
				var oldtime = formatDate(new Date(new Date().getTime() - 2592000000), 'yyyy-MM-dd');
				this.value = [oldtime, nowtime]
				// this.bybtn();
			},
			//返回上一页
			blackbtn() {
				if(this.backid==0){
					uni.navigateBack()
				}else{
					uni.redirectTo({
						url: '../operator_management/operator_management'
					})
				}
				
			},
			gbtn(vul) {
				if (vul == 'a') {
					this.alist = [];
					this.aonRefresh()
				} else if (vul == 'b') {
					this.blist = [];
					this.bonRefresh()
				} else if (vul == 'c') {
					this.clist = [];
					this.conRefresh()
				}

			},
			// 待处理记录分页
			aloadMore() {
				if (this.arefreshing) {
					this.alist = [];
					this.arefreshing = false;
				}
				const that = this;
				let data = {
					type: '0',
					pageNum: that.apageNum,
					pageSize: that.apageSize,
					startTime: that.value[0],
					endTime: that.value[1]
				}
				that.aloading = true;
				that.$base.request1('manager/withdrawal/list', 'GET', data)
					.then(res => {
						that.aloading = false;
						if (res.data.rows && res.data.rows.length > 0) {
							that.alist = that.alist.concat(res.data.rows);
							that.apageNum += 1;
						} else {
							that.afinished = true;
						}
					})
					.catch(err => {

					})
			},
			aonRefresh() {
				// 清空列表数据
				this.afinished = false;
				this.apageNum = 1
				// 重新加载数据
				// 将 loading 设置为 true，表示处于加载状态
				this.aloading = true;
				this.aloadMore();
			},
			// 体现成功记录分页
			bloadMore() {
				if (this.brefreshing) {
					this.blist = [];
					this.brefreshing = false;
				}
				const that = this;
				let data = {
					type: '1',
					pageNum: that.bpageNum,
					pageSize: that.bpageSize,
					startTime: that.value[0],
					endTime: that.value[1]
				}
				that.bloading = true;
				that.$base.request1('manager/withdrawal/list', 'GET', data)
					.then(res => {
						that.bloading = false;
						if (res.data.rows && res.data.rows.length > 0) {
							that.blist = that.blist.concat(res.data.rows);
							that.bpageNum += 1;
						} else {
							that.bfinished = true;
						}
					})
					.catch(err => {

					})
			},
			bonRefresh() {
				// 清空列表数据
				this.bfinished = false;
				this.bpageNum = 1
				// 重新加载数据
				// 将 loading 设置为 true，表示处于加载状态
				this.bloading = true;
				this.bloadMore();
			},

			// 体现失败记录分页
			cloadMore() {
				if (this.crefreshing) {
					this.clist = [];
					this.crefreshing = false;
				}
				const that = this;
				let data = {
					type: '2',
					pageNum: that.cpageNum,
					pageSize: that.cpageSize,
					startTime: that.value[0],
					endTime: that.value[1]
				}
				that.cloading = true;
				that.$base.request1('manager/withdrawal/list', 'GET', data)
					.then(res => {
						that.cloading = false;
						if (res.data.rows && res.data.rows.length > 0) {
							that.clist = that.clist.concat(res.data.rows);
							that.cpageNum += 1;
						} else {
							that.cfinished = true;
						}
					})
					.catch(err => {

					})
			},
			conRefresh() {
				// 清空列表数据
				this.cfinished = false;
				this.cpageNum = 1
				// 重新加载数据
				// 将 loading 设置为 true，表示处于加载状态
				this.cloading = true;
				this.cloadMore();
			},


			//选择时间点击取消
			onCancel() {
				this.showPicker = false;
				var nowtime = formatDate(new Date(), 'yyyy-MM-dd');
				var oldtime = formatDate(new Date(new Date().getTime() - 2592000000), 'yyyy-MM-dd');
				this.value = [oldtime, nowtime]
			},
			//点击时间框选择时间
			onShowDatePicker(type) { //显示
				this.type = type;
				this.showPicker = true;
				this.value = this[type];
			},
			//选择时间点击确定
			onSelected(e) { //选择
				this.showPicker = false;
				if (e) {
					this[this.type] = e.value;
					for (var i = 0; i < e.value.length; i++) {
						e.value[i] = formatDate(new Date(e.value[i]), 'yyyy-MM-dd')
					}
					this.value = e.value;
					if (this.active1 == 'a') {
						this.alist = [];
						this.aonRefresh()
					} else if (this.active1 == 'b') {
						this.blist = [];
						this.bonRefresh()
					} else if (this.active1 == 'c') {
						this.clist = [];
						this.conRefresh()
					}
				}
			},
			h5btn() {
				let data = {
					userId: uni.getStorageSync('userId')
				}
				this.$base.request('manager/baofu/account', 'GET', data)
					.then(res => {
						if (res.data.code==200) {
							Dialog.confirm({
								title: '提示',
								message: "您已支付过开户手续费，接下来将上传资料，进行开户操作",
								confirmButtonColor: '#EC651C',
								confirmButtonText: '确认',
								cancelButtonText: "取消"
												
							}).then(() => {
								var bb=this.twourl.split('?')[0]+'?backid=4000'
								var nowurl=this.oneurl+'#'+bb
								window.location.href = res.data.msg+'?Address='+nowurl
							}).catch(() => {
								
							});
							
						} else if(res.data.code==8000){
							Dialog.confirm({
								title: '提示',
								message: "提现需要开户，检测到您尚未开户，请点击确认按钮支付一次性开户费0.6元。",
								confirmButtonColor: '#EC651C',
								confirmButtonText: '确认',
								cancelButtonText: "取消"
												
							}).then(() => {
								this.bfzcpay()
							}).catch(() => {
								
							});
							
						}else {
							this.$toast.fail(res.data.msg)
						}
					})
					.catch(err => {

					})
			},
			// 宝付注册支付
			bfzcpay(){
				uni.showLoading({
					title: '请稍候',
					mask: true
				})
				this.$base.request('order/saveBFReg', 'POST')
					.then(res => {
						uni.hideLoading()
						if (res.data.code == 200) {
							let arr = res.data.data
							let _this = this
						
							function onBridgeReady() {
								WeixinJSBridge.invoke(
									'getBrandWCPayRequest', {
										"appId": arr.appId, //公众号名称，由商户传入
										"timeStamp": arr.timeStamp, //时间戳，自1970年以来的秒数     
										"nonceStr": arr.nonceStr, //随机串     
										"package": arr.wpackage,
										"signType": arr.signType, //微信签名方式：     
										"paySign": arr.paySign //微信签名 
									},
									function(res) {
										if (res.err_msg == "get_brand_wcpay_request:ok") {
											_this.usertap();
											_this.$toast.success('支付成功')
											uni.redirectTo({
												url: '../index/index'
											})
											
											// 使用以上方式判断前端返回,微信团队郑重提示：
											//res.err_msg将在用户支付成功后返回ok，但并不保证它绝对可靠。
										}else{
											uni.redirectTo({
												url: '../index/index'
											})
										}
									});
							}
							if (typeof WeixinJSBridge == "undefined") {
								if (document.addEventListener) {
									document.addEventListener('WeixinJSBridgeReady', onBridgeReady, false);
								} else if (document.attachEvent) {
									document.attachEvent('WeixinJSBridgeReady', onBridgeReady);
									document.attachEvent('onWeixinJSBridgeReady', onBridgeReady);
								}
							} else {
								onBridgeReady();
							}
						} else {
							this.$toast.fail(res.data.msg)
						}
					})
					.catch(err => {
				
					})
			},
			//划拨查询
			checkTransResult(orderNum) {
				const that=this
				uni.showLoading({
					title: '请稍候',
					mask: true
				})
				that.timer = setInterval(function() {
					console.log(that.times)
					that.times++
					let data = {
						orderNum: orderNum
					}
					that.$base.request('baofu/checkTransResult', 'GET', data)
						.then(res => {
							if (res.data.code == 200) {
								uni.hideLoading()
								clearInterval(that.timer);
								that.timer = null;
								that.times=0
								that.$toast.success(res.data.msg)
							} else if (res.data.code == 4000) {
								uni.hideLoading()
								clearInterval(that.timer);
								that.timer = null;
								that.times=0
								that.h5btn()
							} else if (res.data.code == 4001) {
								uni.hideLoading()
								clearInterval(that.timer);
								that.timer = null;
								that.times=0
								Dialog.confirm({
									title: '提示',
									message: res.data.msg
								}).then(() => {
									var bb=that.twourl.split('?')[0]+'?backid=4001'
									var nowurl=that.oneurl+'#'+bb
									window.location.href = res.data.data+'?Address='+nowurl
								}).catch(() => {
					
								});
							} else if (res.data.code == 4002) {
								uni.hideLoading()
								clearInterval(that.timer);
								that.timer = null;
								that.times=0
								Dialog.confirm({
									title: '提示',
									message: res.data.msg
								}).then(() => {
									var bb=that.twourl.split('?')[0]+'?backid=4002'
									var nowurl=that.oneurl+'#'+bb
									window.location.href = res.data.data+'?Address='+nowurl
								}).catch(() => {
							
								});
							}else if (res.data.code == 4003) {
								uni.hideLoading()
								clearInterval(that.timer);
								that.timer = null;
								that.times=0
								Dialog.confirm({
									title: '提示',
									message: '您正在进行银行卡提现，点击确认跳转至输入支付密码页面'
								}).then(() => {
									var bb=that.twourl.split('?')[0]+'?backid=4003'
									var nowurl=that.oneurl+'#'+bb
									window.location.href = res.data.data+'?Address='+nowurl
								}).catch(() => {
					
								});
							}else if(res.data.code == 4008){
								console.log('11111')
								if(that.times==3){
									console.log('22222')
									uni.hideLoading()
									clearInterval(that.timer);
									that.timer = null;
									that.times=0
									Dialog.alert({
									  title: '提示',
									  message: '您的提现申请已成功提交，请10分钟后在［提现记录］-［待处理］中点击“提现到卡”按钮进行最后提现操作。',
									}).then(() => {
									  // on close
									});
								}
							}else{
								console.log('33333')
								if(that.times==3){
									console.log('44444')
									uni.hideLoading()
									clearInterval(that.timer);
									that.timer = null;
									that.times=0
									var toast = Toast({
										duration: 4000,
										message: ''
									})
									toast.message = res.data.msg
								}
							}
					
						})
						.catch(err => {
					
						})
				}, 2000);

			},
			//划拨查询
			checkTransResult1(orderNum) {
				let data = {
					orderNum: orderNum
				}
				this.$base.request('baofu/checkTransResult', 'GET', data)
					.then(res => {
						if (res.data.code == 200) {
							this.$toast.success(res.data.msg)
						} else if (res.data.code == 4000) {
							this.h5btn()
						} else if (res.data.code == 4001) {

							Dialog.confirm({
								title: '提示',
								message: res.data.msg
							}).then(() => {
								var bb=this.twourl.split('?')[0]+'?backid=4002'
								var nowurl=this.oneurl+'#'+bb
								window.location.href = res.data.data+'?Address='+nowurl
							}).catch(() => {

							});
						} else if (res.data.code == 4002) {

							Dialog.confirm({
								title: '提示',
								message: res.data.msg
							}).then(() => {
								var bb=this.twourl.split('?')[0]+'?backid=4002'
								var nowurl=this.oneurl+'#'+bb
								window.location.href = res.data.data+'?Address='+nowurl
							}).catch(() => {

							});
						}else if (res.data.code == 4003) {

							Dialog.confirm({
								title: '提示',
								message: '您正在进行银行卡提现，点击确认跳转至输入支付密码页面'
							}).then(() => {
								var bb=this.twourl.split('?')[0]+'?backid=4003'
								var nowurl=this.oneurl+'#'+bb
								window.location.href = res.data.data+'?Address='+nowurl
							}).catch(() => {

							});
						}else if(res.data.code == 4008){
							Dialog.alert({
							  title: '提示',
							  message: '您的资金尚未到账，请稍后重试',
							}).then(() => {
							  // on close
							});
						}else {

							var toast = Toast({
								duration: 4000,
								message: ''
							})
							toast.message = res.data.msg
						}
					})
					.catch(err => {

					})
			},
			mbtn(orderNum) {
				this.checkTransResult1(orderNum)
			},
			//企业注册
			qybtn() {
				let data = {
					userId: uni.getStorageSync('userId'),
					email: this.email
				}
				this.$base.request('manager/baofu/accountPc', 'GET', data)
					.then(res => {
						if (res.data.code == 200) {
							this.$toast.success(res.data.msg)
							this.eshow = false
						} else {
							this.$toast.fail(res.data.msg)
							this.eshow = false
						}
					})
					.catch(err => {

					})
			},
			//合利宝提现到卡
			hlbbtn(orderNum){
				let data = {
					orderNum: orderNum,
					token:uni.getStorageSync('userToken')
				}
				this.$base.request('party/withdral/managerWithdraltocard', 'POST', data)
					.then(res => {
						if (res.data.code == 200) {
							this.$toast.success(res.data.msg)
							this.active=0
							this.activeNames1=[]
						} else {
							var toast = Toast({
								duration: 4000,
								message: ''
							})
							toast.message = res.data.msg
						}
					})
					.catch(err => {
				
					})
			},
			//解绑银行卡
			jbtn(){
				this.$base.request('manager/baofu/channel/type', 'GET')
					.then(res => {
						if (res.data.code == 200) {
							Dialog.confirm({
								title: '提示',
								message: res.data.msg
							}).then(() => {
								if(res.data.data=='Z'){
									let data = {
										userId: uni.getStorageSync('userId'),
									}
									this.$base.request('manager/baofu/cardPerson', 'GET', data)
										.then(res1 => {
											if (res1.data.code == 200) {
												window.location.href = res1.data.msg
											} else {
												this.$toast.fail(res1.data.msg)
											}
										})
										.catch(err => {
									
										})
								}else if(res.data.data=='H'){
									uni.navigateTo({
										url: '../unbind_private_card/unbind_private_card'
									});
								}
								
							}).catch(() => {
							});
						} else {
							this.$toast.fail(res.data.msg)
						}
					})
					.catch(err => {
				
					})
				
			}
		}
	}
</script>

<style lang="scss" scoped>
	.main {
		width: 100%;
		overflow-x: hidden;
		background-color: #F5F5F5;

		/deep/.van-list__finished-text {
			margin-top: 100upx;
			padding-bottom: 200upx;
		}

		/deep/.van-hairline--top-bottom::after {
			border-width: 0;
		}
		.hand{
			text-size-adjust: 100% !important;
			-webkit-text-size-adjust: 100% !important;  
			-moz-text-size-adjust: 100% !important;
			width: 100%;
			background-color: #4B98ED;
			font-size: 30upx;
			padding: 20upx 0;
			font-family: PingFang SC Bold, PingFang SC Bold-Bold;
			font-weight: 700;
			text-align: center;
			color: #ffffff;
			position: relative;
			image{
				width:22upx;
				height: 39upx;
				position: absolute;
				left: 31upx;
				top: 22upx;
			}
		}
		.show {
			/deep/.van-tabs__nav {
				background-color: #F7F7F7;
			}

			/deep/.van-tab {
				font-size: 32upx;
				font-family: PingFang SC Bold, PingFang SC Bold-Bold;
				font-weight: 700;
				color: #999999;
			}

			/deep/.van-tab--active {
				font-size: 32upx;
				font-family: PingFang SC Bold, PingFang SC Bold-Bold;
				font-weight: 700;
				color: #4b98ed;
			}

			/deep/.van-tabs__line {
				width: 210upx !important;
				height: 4upx;
				border-radius: 2px;
				background-color: #4B98ED;
			}

			.sone {
				width: 100%;
				background-color: #FFFFFF;
				box-sizing: border-box;
				padding: 52upx;

				input {
					font-size: 28upx;
					font-family: PingFang SC Medium, PingFang SC Medium-Medium;
					font-weight: 500;
					color: #999999;
					border-bottom: 1upx solid #ebebeb;
					padding: 11upx 11upx;
				}

				.sonehand {
					width: 100%;
					display: flex;
					justify-content: space-between;
					margin-top: 30upx;

					.soneleft {
						font-size: 24upx;
						font-family: PingFang SC Medium, PingFang SC Medium-Medium;
						font-weight: 500;
						color: #333333;

						.slefttxt {
							font-size: 28upx;
							color: #4B98ED;
							margin-left: 11upx;
						}
					}
				}
				.sonejb{
					width: 135upx;
					text-align: center;
					border-radius: 8upx;
					background-color: #4B98ED;
					font-size: 22upx;
					font-family: PingFang SC Bold, PingFang SC Bold-Bold;
					font-weight: 700;
					color: #ffffff;
					height: 50upx;
					line-height: 50upx;
					margin: 20upx 0;
				}
				.sonez {
					width: 500upx;
					height: 88upx;
					border-radius: 16upx;
					background-color: #4B98ED;
					font-size: 32upx;
					font-family: PingFang SC Bold, PingFang SC Bold-Bold;
					font-weight: 700;
					text-align: center;
					line-height: 88upx;
					margin: 40upx auto;
					color: #ffffff;
				}
			}

			.sonexia {
				width: 100%;
				box-sizing: border-box;
				padding: 0upx 33upx 0upx 33upx;
				font-size: 24upx;
				font-family: PingFang SC Medium, PingFang SC Medium-Medium;
				font-weight: 500;
				line-height: 45upx;
				margin-top: 30upx;

				.sxone {
					color: #333333;
				}

				.sxtwo {
					color: #666666;
				}
			}

			.cdjl-0 {
				display: flex;
				height: 100upx;
				background: #fff;
				align-items: center;
				justify-content: space-around;

				.cdjl-0-l {
					height: 60upx;
					width: 260upx;
					border-radius: 10upx;
					border: 2upx solid #ccc;
					font-size: 30upx;
					line-height: 60upx;
					color: #bbbbbb;
					text-align: center;
				}

				.cdjl-0-r {
					width: 120upx;
					height: 60upx;
					font-size: 20upx;
					background: #4e9ff6;
					color: #fff;
					line-height: 60upx;
					text-align: center;
					border-radius: 10upx;
				}
			}

			.tapthree {
				margin: 16upx auto;
				width: 686upx;
				// background-color: #F5F5F5;

				.tphand {
					font-size: 28upx;
					font-family: PingFang SC Bold, PingFang SC Bold-Bold;
					font-weight: 700;
					color: #333333;
				}

				.ztai {
					font-size: 24upx;
					font-family: PingFang SC Bold, PingFang SC Bold-Bold;
					font-weight: 700;
					text-align: right;
					color: #4b98ed;
				}

				.tpfoot {
					font-size: 24upx;
					font-family: PingFang SC Medium, PingFang SC Medium-Medium;
					font-weight: 500;
					color: #666666;
					margin-top: 10upx;
				}

				/deep/.van-cell__title {
					display: flex;
					justify-content: space-between;
					align-items: center;
				}

				/deep/.van-collapse {
					// background-color: #F5F5F5;
				}

				/deep/.van-collapse-item {
					margin-top: 22upx;
				}

				/deep/.van-collapse-item__content {
					padding: 0 30upx;
				}

				/deep/.van-cell {
					align-items: center;
					padding: 10upx 10upx;
					border-radius: 16upx;
					// box-shadow: 0upx 4upx 9upx 0upx rgba(44,44,44,0.21); 
					margin-bottom: 20upx;
				}

				/deep/.van-collapse-item {
					margin-top: 10upx;
				}

				.showtap {
					width: 100%;
					box-sizing: border-box;
					padding: 21upx 0;

					.stone {
						width: 100%;
						box-sizing: border-box;
						display: flex;
						margin-bottom: 15upx;
						padding: 0 30upx;

						.stoneleft {
							font-size: 24upx;
							font-family: PingFang SC Medium, PingFang SC Medium-Medium;
							font-weight: 500;
							color: #666666;
							margin-right: 40upx;
						}

						.stoneright {
							font-size: 24upx;
							font-family: PingFang SC Bold, PingFang SC Bold-Bold;
							font-weight: 700;
							color: #333333;
						}

						.strone {
							color: #F078CE;
						}

						.strtwo {
							color: #4BED79;
						}

						.strthree {
							color: #4B98ED;
						}
					}

					.stwo {
						width: 130upx;
						border-radius: 8upx;
						background-color: #4B98ED;
						font-size: 25upx;
						font-family: PingFang SC Bold, PingFang SC Bold-Bold;
						font-weight: 700;
						text-align: center;
						padding: 15upx 0;
						margin-left: 30upx;
						color: #ffffff;
					}
				}

			}

			.vshand {
				width: 100%;
				display: flex;
				justify-content: center;
				box-sizing: border-box;
				align-items: center;
				margin-top: 46upx;

				input {
					width: 250upx;
					height: 64upx;
					font-size: 28upx;
					font-family: PingFang SC Medium, PingFang SC Medium-Medium;
					font-weight: 500;
					color: #999999;
					border: 1upx solid #d2d2d2;
					padding-left: 30upx;
					box-sizing: border-box;
					border-radius: 8upx;
				}

				.vstxt {
					width: 32upx;
					height: 2upx;
					background-color: #313131;
					margin: 0 10upx;
				}

				.vsbtn {
					width: 77upx;
					height: 64upx;
					border-radius: 10upx;
					font-size: 24upx;
					font-family: PingFang SC Bold, PingFang SC Bold-Bold;
					font-weight: 700;
					text-align: center;
					line-height: 64upx;
					background-color: #4B98ED;
					color: #ffffff;
					margin-left: 39upx;
				}
			}
		}

		/deep/.van-popup--center {
			border-radius: 20upx;
		}

		.tannei {
			width: 686upx;
			background-color: #fff;

			.tfshow {
				width: 260upx;
				border-radius: 8upx;
				background-color: #4B98ED;
				font-size: 16upx;
				font-family: PingFang SC Bold, PingFang SC Bold-Bold;
				font-weight: 700;
				text-align: center;
				padding: 15upx 0;
				margin: 20upx auto;
				color: #ffffff;
			}

			.eone {
				display: flex;
				font-size: 26upx;
				font-family: PingFang SC Bold, PingFang SC Bold-Bold;
				font-weight: 700;
				align-items: center;
				justify-content: center;
				margin: 100upx 0;

				input {
					width: 60%;
					font-size: 28upx;
					font-family: PingFang SC Medium, PingFang SC Medium-Medium;
					font-weight: 500;
					color: #999999;
					border: 1upx solid #ebebeb;
					padding: 11upx 11upx;
					margin-left: 20upx;
				}
			}
		}
	}
</style>
